// 1. 创建链接

const mongoose = require('mongoose');

mongoose.connect('mongodb://127.0.0.1:27017/todoList');

mongoose.connection.on('open', ()=>{
    console.log('数据库链接成功');
    const todoListSchema = new mongoose.Schema({
        title:String,
        isDone:{
            type:Boolean,
            default:false
        }
    })
    const todoListModel = mongoose.model('todoList', todoListSchema, 'todoList');
    todoListModel.find({}).then(value=>{
        console.log(value);
    })
    
})

mongoose.connection.on('error', ()=>{
    console.log('数据库链接失败');
})